(function(){
    'use strict';
    angular.module('module.business')
        .controller('PersonInfoController', PersonInfoController);

    PersonInfoController.$inject= ['$scope','$http','$uibModalInstance','i18nService'];

    function PersonInfoController($scope,$http,$uibModalInstance,i18nService) {
        var vm = $scope;
        vm.ok = ok;                                     //点击'是'按钮时执行
        vm.cancel = cancel;                             //点击'否'按钮时执行
        vm.activate=activate;

        vm.gridOptions = {
            multiSelect: true,                                           //多选
            enableRowSelection: true,                                  //允许选中行
            //showGridFooter:true,
            enableRowHeaderSelection: false,//允许通过点击行首选中行
            enableColumnResizing : true,//设置宽度
            enableGridMenu: true,
            enableFullRowSelection: true,                              //允许通过点击行任意位置选中行
            modifierKeysToMultiSelect: true,                           //只允许通过键盘辅助多选(前提是允许多选)
            paginationPageSize: 10,
            paginationPageSizes: [10, 20, 50]

        };
        i18nService.setCurrentLang('zh-cn');
        vm.gridOptions.onRegisterApi = onRegisterApi;
        vm.gridOptions.columnDefs = [
            {field: 'NUMBER', visible: true, name: '序号', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'70'},
            {field: 'NAME', visible: true, name: '姓名', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'CETR_NO', visible: true, name: '证书编号', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'CETR_RANK', visible: true, name: '证书级别', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'PHONE', visible: true, name: '联系电话', pinnedLeft: true,cellTooltip: true,headerTooltip: true}
        ];

        activate();
        return vm;

        function activate() {
            $http.get('app/module/business/evaluation/organization/organization-person.json')
                .then(function(data){
                    vm.gridOptions.data = data.data.record;
                });

        }

        function onRegisterApi(gridApi) {
            //set gridApi on scope
            vm.gridApi = gridApi;
        }


        /**
         * @description 点击'是'按钮时执行
         */
        function ok() {
            $uibModalInstance.close(selected);
        }

        /**
         * @description 点击'否'按钮时执行
         */
        function cancel() {
            $uibModalInstance.dismiss('cancel');
        }
    }
})();